﻿{extend name="public:base" /}

{block name="content"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox ">
                <div class="ibox-title">
                    <a href="{:url('doSettlementRule')}" class="btn btn-primary btn-lg">新增</a>

                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="iconfont icon-chevron-up"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    <div class="row search-form">
                        <div class="col-sm-2 m-b-sm">
                            <div class="input-group">
                                <input placeholder="请输入流水单号" name="sn" value="{:input('sn')}" type="text" class="form-control form-control-lg">
                            </div>
                        </div>
                        <div class="col-sm-2 m-b-sm">
                            <div class="input-group" style="display: flex;">
                                <button type="button" class="btn btn-primary btn-lg screen-btn">搜索</button>
                                <button type="button" class="btn btn-warning btn-lg other-btn" style="margin-left: 30px">批量原路退款</button>
                            </div>
                        </div>
                    </div>

                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th><input type="checkbox" id="checkAll"></th>
                                <th>流水单号</th>
                                <th>时间</th>
                                <th>类型</th>
                                <th>金额</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td><input type="checkbox" name="refundIds[]" value="1"></td>
                                <td>SN20251111111</td>
                                <td>2025-11-12 22:00:00</td>
                                <td>拨付</td>
                                <td>￥80,000</td>
                                <td>未上课</td>
                                <td>
                                    <a href="{:url('refundDetail', ['id' => $vo.id])}" class="btn btn-white btn-sm"><i class="iconfont icon-eye"></i> 查看
                                    </a>
                                    <a href="{:url('backRefund', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate"><i class="iconfont icon-zijinguanli"></i> 原路退款
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" name="refundIds[]" value="2"></td>
                                <td>SN20251111111</td>
                                <td>2025-11-12 22:00:00</td>
                                <td>拨付</td>
                                <td>￥80,000</td>
                                <td>未上课</td>
                                <td>
                                    <a href="{:url('refundDetail', ['id' => $vo.id])}" class="btn btn-white btn-sm"><i class="iconfont icon-eye"></i> 查看
                                    </a>
                                    <a href="{:url('backRefund', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate"><i class="iconfont icon-zijinguanli"></i> 原路退款
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" name="refundIds[]" value="2"></td>
                                <td>SN20251111111</td>
                                <td>2025-11-12 22:00:00</td>
                                <td>拨付</td>
                                <td>￥80,000</td>
                                <td>未上课</td>
                                <td>
                                    <a href="{:url('refundDetail', ['id' => $vo.id])}" class="btn btn-white btn-sm"><i class="iconfont icon-eye"></i> 查看
                                    </a>
                                    <a href="{:url('backRefund', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate"><i class="iconfont icon-zijinguanli"></i> 原路退款
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" name="refundIds[]" value="2"></td>
                                <td>SN20251111111</td>
                                <td>2025-11-12 22:00:00</td>
                                <td>拨付</td>
                                <td>￥80,000</td>
                                <td>未上课</td>
                                <td>
                                    <a href="{:url('refundDetail', ['id' => $vo.id])}" class="btn btn-white btn-sm"><i class="iconfont icon-eye"></i> 查看
                                    </a>
                                    <a href="{:url('backRefund', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate"><i class="iconfont icon-zijinguanli"></i> 原路退款
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" name="refundIds[]" value="2"></td>
                                <td>SN20251111111</td>
                                <td>2025-11-12 22:00:00</td>
                                <td>拨付</td>
                                <td>￥80,000</td>
                                <td>未上课</td>
                                <td>
                                    <a href="{:url('refundDetail', ['id' => $vo.id])}" class="btn btn-white btn-sm"><i class="iconfont icon-eye"></i> 查看
                                    </a>
                                    <a href="{:url('backRefund', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate"><i class="iconfont icon-zijinguanli"></i> 原路退款
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" name="refundIds[]" value="2"></td>
                                <td>SN20251111111</td>
                                <td>2025-11-12 22:00:00</td>
                                <td>拨付</td>
                                <td>￥80,000</td>
                                <td>未上课</td>
                                <td>
                                    <a href="{:url('refundDetail', ['id' => $vo.id])}" class="btn btn-white btn-sm"><i class="iconfont icon-eye"></i> 查看
                                    </a>
                                    <a href="{:url('backRefund', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate"><i class="iconfont icon-zijinguanli"></i> 原路退款
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" name="refundIds[]" value="2"></td>
                                <td>SN20251111111</td>
                                <td>2025-11-12 22:00:00</td>
                                <td>拨付</td>
                                <td>￥80,000</td>
                                <td>未上课</td>
                                <td>
                                    <a href="{:url('refundDetail', ['id' => $vo.id])}" class="btn btn-white btn-sm"><i class="iconfont icon-eye"></i> 查看
                                    </a>
                                    <a href="{:url('backRefund', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate"><i class="iconfont icon-zijinguanli"></i> 原路退款
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" name="refundIds[]" value="2"></td>
                                <td>SN20251111111</td>
                                <td>2025-11-12 22:00:00</td>
                                <td>拨付</td>
                                <td>￥80,000</td>
                                <td>未上课</td>
                                <td>
                                    <a href="{:url('refundDetail', ['id' => $vo.id])}" class="btn btn-white btn-sm"><i class="iconfont icon-eye"></i> 查看
                                    </a>
                                    <a href="{:url('backRefund', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate"><i class="iconfont icon-zijinguanli"></i> 原路退款
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" name="refundIds[]" value="2"></td>
                                <td>SN20251111111</td>
                                <td>2025-11-12 22:00:00</td>
                                <td>拨付</td>
                                <td>￥80,000</td>
                                <td>未上课</td>
                                <td>
                                    <a href="{:url('refundDetail', ['id' => $vo.id])}" class="btn btn-white btn-sm"><i class="iconfont icon-eye"></i> 查看
                                    </a>
                                    <a href="{:url('backRefund', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate"><i class="iconfont icon-zijinguanli"></i> 原路退款
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" name="refundIds[]" value="2"></td>
                                <td>SN20251111111</td>
                                <td>2025-11-12 22:00:00</td>
                                <td>拨付</td>
                                <td>￥80,000</td>
                                <td>未上课</td>
                                <td>
                                    <a href="{:url('refundDetail', ['id' => $vo.id])}" class="btn btn-white btn-sm"><i class="iconfont icon-eye"></i> 查看
                                    </a>
                                    <a href="{:url('backRefund', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate"><i class="iconfont icon-zijinguanli"></i> 原路退款
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" name="refundIds[]" value="2"></td>
                                <td>SN20251111111</td>
                                <td>2025-11-12 22:00:00</td>
                                <td>拨付</td>
                                <td>￥80,000</td>
                                <td>未上课</td>
                                <td>
                                    <a href="{:url('refundDetail', ['id' => $vo.id])}" class="btn btn-white btn-sm"><i class="iconfont icon-eye"></i> 查看
                                    </a>
                                    <a href="{:url('backRefund', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate"><i class="iconfont icon-zijinguanli"></i> 原路退款
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" name="refundIds[]" value="2"></td>
                                <td>SN20251111111</td>
                                <td>2025-11-12 22:00:00</td>
                                <td>拨付</td>
                                <td>￥80,000</td>
                                <td>未上课</td>
                                <td>
                                    <a href="{:url('refundDetail', ['id' => $vo.id])}" class="btn btn-white btn-sm"><i class="iconfont icon-eye"></i> 查看
                                    </a>
                                    <a href="{:url('backRefund', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate"><i class="iconfont icon-zijinguanli"></i> 原路退款
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" name="refundIds[]" value="2"></td>
                                <td>SN20251111111</td>
                                <td>2025-11-12 22:00:00</td>
                                <td>拨付</td>
                                <td>￥80,000</td>
                                <td>未上课</td>
                                <td>
                                    <a href="{:url('refundDetail', ['id' => $vo.id])}" class="btn btn-white btn-sm"><i class="iconfont icon-eye"></i> 查看
                                    </a>
                                    <a href="{:url('backRefund', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate"><i class="iconfont icon-zijinguanli"></i> 原路退款
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" name="refundIds[]" value="2"></td>
                                <td>SN20251111111</td>
                                <td>2025-11-12 22:00:00</td>
                                <td>拨付</td>
                                <td>￥80,000</td>
                                <td>未上课</td>
                                <td>
                                    <a href="{:url('refundDetail', ['id' => $vo.id])}" class="btn btn-white btn-sm"><i class="iconfont icon-eye"></i> 查看
                                    </a>
                                    <a href="{:url('backRefund', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate"><i class="iconfont icon-zijinguanli"></i> 原路退款
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" name="refundIds[]" value="2"></td>
                                <td>SN20251111111</td>
                                <td>2025-11-12 22:00:00</td>
                                <td>拨付</td>
                                <td>￥80,000</td>
                                <td>未上课</td>
                                <td>
                                    <a href="{:url('refundDetail', ['id' => $vo.id])}" class="btn btn-white btn-sm"><i class="iconfont icon-eye"></i> 查看
                                    </a>
                                    <a href="{:url('backRefund', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate"><i class="iconfont icon-zijinguanli"></i> 原路退款
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" name="refundIds[]" value="2"></td>
                                <td>SN20251111111</td>
                                <td>2025-11-12 22:00:00</td>
                                <td>拨付</td>
                                <td>￥80,000</td>
                                <td>未上课</td>
                                <td>
                                    <a href="{:url('refundDetail', ['id' => $vo.id])}" class="btn btn-white btn-sm"><i class="iconfont icon-eye"></i> 查看
                                    </a>
                                    <a href="{:url('backRefund', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate"><i class="iconfont icon-zijinguanli"></i> 原路退款
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td><input type="checkbox" name="refundIds[]" value="2"></td>
                                <td>SN20251111111</td>
                                <td>2025-11-12 22:00:00</td>
                                <td>拨付</td>
                                <td>￥80,000</td>
                                <td>未上课</td>
                                <td>
                                    <a href="{:url('refundDetail', ['id' => $vo.id])}" class="btn btn-white btn-sm"><i class="iconfont icon-eye"></i> 查看
                                    </a>
                                    <a href="{:url('backRefund', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate"><i class="iconfont icon-zijinguanli"></i> 原路退款
                                    </a>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                        {if !empty($list)}{$list->render()}{/if}
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

{/block}

{block name="js"}
<script>
    // 全选/取消全选
    $('#checkAll').on('click', function () {
        var isChecked = $(this).prop('checked');
        $('input[name="refundIds[]"]').prop('checked', isChecked);
    });

    // 单个checkbox点击时，检查是否所有都选中
    $('input[name="refundIds[]"]').on('click', function () {
        var total = $('input[name="refundIds[]"]').length;
        var checked = $('input[name="refundIds[]"]:checked').length;
        $('#checkAll').prop('checked', total === checked);
    });

    // 批量原路退款按钮点击事件
    $('.other-btn').on('click', function () {
        var selectedIds = $('input[name="refundIds[]"]:checked');

        if (selectedIds.length === 0) {
            layer.msg('请至少选择一条记录进行退款操作', {icon: 5});
            return;
        }

        layer.confirm('确定要对选中的 ' + selectedIds.length + ' 条记录进行批量原路退款吗？', {
            btn: ['确定', '取消'],
            icon: 3
        }, function () {
            // 构建选中的ID数组
            var ids = [];
            selectedIds.each(function () {
                ids.push($(this).val());
            });

            // 显示加载中
            var index = layer.load();

            // 发送AJAX请求
            $.ajax({
                url: '{:url("batchBackRefund")}',
                type: 'POST',
                data: {ids: ids},
                dataType: 'json',
                success: function (res) {
                    layer.close(index);
                    if (res.code === 1) {
                        layer.msg(res.msg || '批量退款操作成功', {icon: 6}, function () {
                            window.location.reload();
                        });
                    } else {
                        layer.msg(res.msg || '批量退款操作失败', {icon: 5});
                    }
                },
                error: function () {
                    layer.close(index);
                    layer.msg('网络错误，请稍后重试', {icon: 5});
                }
            });
        });
    });
</script>
{/block}